#ifndef LEVELSCENE_H
#define LEVELSCENE_H

#include "gamescene.h"
#include <QWidget>
#include <QApplication>
#include <QMouseEvent>
#include <QList>
#include <QPixmap>
#include <QImage>

#include "gamebackground.h"
#include "toolbutton.h"
#include "minimap.h"
#include "building.h"
#include "optionspanel.h"

//Pathfinding stuff
#include "pathfinder.h"
#include <stdlib.h>

#define RESOURCE_DIR QApplication::applicationDirPath() + "/../../resources"

class LevelScene : public GameScene
{
    Q_OBJECT

public:
    LevelScene(QPixmap mapPixmap, QImage mapMask, QWidget *parent);

    ToolButton * addTool(QString caption, QPixmap toolIcon);
    Building * addBuilding(QPoint enterence, qreal x, qreal y, QPixmap buildingPixmap);
    Person * addPerson(qreal x, qreal y, QPixmap personPixmap);

    void start();
    void pauseScene();

    QList<Building*> buildings;

public slots:
    void toolClicked(ToolButton * sender);
    void buildingClicked(Building * sender);
    void pathSolved(std::vector<void*> path, QObject * receiver);
    void setBuilding(Person * person, Building * building);

    void resumeScene();
    void endScene(GameScene::GameScenes nextScene);

signals:
    void startPeople();
    void stopPeople();
	
protected:
    QList<ToolButton*> tools;
    QList<Person*> people;

    void keyPressEvent(QKeyEvent * event);

private:
    // Stuff for the map
    GameBackground * map;

    // All the stuff for the tools panel
    QGraphicsView * panelView;
    QGraphicsScene * panelScene;
    GameBackground * panelBackground;
    ToolButton * currentTool;

    // The minimap object
    MiniMap * miniMap;

    // The options panel object
    OptionsPanel * optionsPanel;

    PathFinder * pathFinder;

};

#endif // LEVELSCENE_H
